using EnvDTE;
using Microsoft.Practices.RecipeFramework.VisualStudio.Templates;
using System;
using System.Runtime.Serialization;

namespace VSSDKAssist.Assets.References.Base
{
	/// <summary>
	/// Base template reference base class
	/// </summary>
	[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2240:ImplementISerializableCorrectly"), Serializable]
	public abstract class TemplateReferenceBase : UnboundTemplateReference
	{
		#region Fields
		private DTE visualStudio; 
		#endregion

		#region Constructors
		/// <summary>
		/// Initializes a new instance of the <see cref="RecipeReferenceBase"/> class.
		/// </summary>
		/// <param name="recipe">The recipe.</param>
		protected TemplateReferenceBase(string recipe)
			: base(recipe)
		{
		}
		#endregion

		#region Properties
		/// <summary>
		/// Gets the visual studio.
		/// </summary>
		/// <value>The visual studio.</value>
		protected DTE VisualStudio
		{
			get
			{
				if(this.visualStudio == null)
				{
					this.visualStudio = this.GetService<DTE>(true);
				}

				return this.visualStudio;
			}
		}
		#endregion

		#region ISerializable Members

		/// <summary>
		/// Required constructor for deserialization.
		/// </summary>
		protected TemplateReferenceBase(SerializationInfo info, StreamingContext context)
			: base(info, context)
		{
		}

		#endregion ISerializable Members
	}
}